import { requestClient } from '#/api/request';

export namespace CmtMerchantInfoApi {
  /** 商户信息 */
  export interface MerchantInfo {
    id?: number;
    communityId?: number;
    merchantNo?: string;
    name: string;
    shortName?: string;
    logo?: string;
    merchantType?: number;
    businessLicense?: string;
    licenseNo?: string;
    legalPerson?: string;
    contactPerson?: string;
    contactPhone?: string;
    contactEmail?: string;
    province?: string;
    city?: string;
    district?: string;
    address?: string;
    introduction?: string;
    serviceScope?: string;
    adminUserId?: number;
    auditStatus?: number;
    auditUserId?: number;
    auditTime?: string;
    auditRemark?: string;
    merchantStatus?: number;
    expireTime?: string;
    sort?: number;
    status?: number;
    remark?: string;
    createTime?: string;
  }

  /** 商户信息分页查询参数 */
  export interface MerchantInfoPageReqVO {
    pageNo: number;
    pageSize: number;
    name?: string;
    merchantNo?: string;
    communityId?: number;
    merchantType?: number;
    auditStatus?: number;
    merchantStatus?: number;
    status?: number;
    createTime?: string[];
  }
}

/** 查询商户信息分页 */
export function getMerchantInfoPage(params: CmtMerchantInfoApi.MerchantInfoPageReqVO) {
  return requestClient.get<any>('/cmt/base-merchant-info/page', { params });
}

/** 查询商户信息详情 */
export function getMerchantInfo(id: number) {
  return requestClient.get<CmtMerchantInfoApi.MerchantInfo>('/cmt/base-merchant-info/get', {
    params: { id },
  });
}

/** 新增商户信息 */
export function createMerchantInfo(data: CmtMerchantInfoApi.MerchantInfo) {
  return requestClient.post<number>('/cmt/base-merchant-info/create', data);
}

/** 修改商户信息 */
export function updateMerchantInfo(data: CmtMerchantInfoApi.MerchantInfo) {
  return requestClient.put<boolean>('/cmt/base-merchant-info/update', data);
}

/** 删除商户信息 */
export function deleteMerchantInfo(id: number) {
  return requestClient.delete<boolean>('/cmt/base-merchant-info/delete?id=' + id);
}

/** 批量删除商户信息 */
export function deleteMerchantInfoList(ids: number[]) {
  return requestClient.delete<boolean>(
    '/cmt/base-merchant-info/delete-list?ids=' + ids.join(','),
  );
}

/** 导出商户信息 Excel */
export function exportMerchantInfo(params: CmtMerchantInfoApi.MerchantInfoPageReqVO) {
  return requestClient.get<Blob>('/cmt/base-merchant-info/export-excel', {
    params,
    responseType: 'blob',
  });
}

/** 获取商户选项列表(用于下拉选择) */
export function getMerchantInfoOptions() {
  return requestClient.get<any>('/cmt/base-merchant-info/page', {
    params: { pageNo: -1, pageSize: 10 },
  });
}
